package com.tarena.day05_all;

import java.util.Random;
import java.util.Scanner;

public class AdditonalTest {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Random ran = new Random();
		int answer;
		while(true){
			System.out.println("请选择测试是否开始，开始/退出：\"Y\"/\"Q\"");
			String command = sc.next().trim();
			if(command.equalsIgnoreCase("Q")){
				System.out.println("退出考试系统。。。");
				break;
			}else if(command.equalsIgnoreCase("Y")){
				System.out.println("考试开始：");
			}else{
				continue;
			}
			double score = 0;
			double questionsNumber = 10;
			double total = 100;
			for(int i = 1 ; i <= 10; i++){
				int a = ran.nextInt(100);
				int b = ran.nextInt(100);
				System.out.print(i + ") " + a + " + " + b + " = " + "? ");
				answer = sc.nextInt();
				if(a + b == answer){
					System.out.println("pefect!");
					score += total / questionsNumber;
				}else{
					System.out.println("Error!");
				}
			}
			System.out.println("您本次测试的得分是：" + score);
		}
	}
}
